package Java9_8.Test_2;


import java.util.HashSet;
import java.util.Set;

public class Conpany {
    private String name;//公司名称
    private String addess;//公司地址
    private String tel;//电话
    private String exp;//经营范围
   Set s=new HashSet();

    public Conpany(String name, String addess, String tel, String exp) {
        this.name = name;
        this.addess = addess;
        this.tel = tel;
        this.exp = exp;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddess() {
        return addess;
    }

    public void setAddess(String addess) {
        this.addess = addess;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getExp() {
        return exp;
    }

    public void setExp(String exp) {
        this.exp = exp;
    }
    //招聘员工(要求工号不能重复)
    public void add(Staff staff) {
        for (Object x:s) {
            Staff s=(Staff) x;
            if (s.getJobNumber().equals(((Staff) x).getJobNumber())) {
                System.out.println("输入工号重复，添加失败");
                return ;
            }
        }
        s.add(staff);
        System.out.println("添加成功");
    }
    //输出公司信息

    @Override
    public String toString() {
        return "公司{" +
                "名字='" + name + '\'' +
                ", 地址='" + addess + '\'' +
                ", 电话='" + tel + '\'' +
                ", 经营范围='" + exp + '\'' +
                '}';
    }
    //输出员工信息
    public void show(){
        for (Object x:s){
            Staff a=(Staff) x;
            if (a==null){
                System.out.println("没有员工");
                break;
            }else if (a!=null){
                System.out.println("员工信息如下");
                System.out.println(a.toString());
            }
        }
    }
    //辞退员工方法
    public void delete(Staff staff){
        for (Object x:s){
            Staff a=(Staff) x;
            if (a.getJobNumber().equals(((Staff) x).getJobNumber())){
                s.remove(a);
                System.out.println("辞退员工成功");
                return ;
            }
        }
        System.out.println("没有该员工");
        return;
    }
    //统计公司人数
    public  void  rs(){
        System.out.println(s.size()+"人");
    }
    //获得公司薪水最高的员工
    public Staff  max(){
        Staff s1=new Staff();
        for (Object x: s){
            Staff a=(Staff) x;
            if (a.getPay()>s1.getPay()){
                s1=a;
            }
        }
        return s1;
    }
}
